//
//  VideoDetailViewController.m
//  copyrightTrading
//
//  Created by edz on 2020/10/9.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "VideoDetailViewController.h"
#import "VideoDetailSectionOneCell.h"
#import "MineCartViewController.h"
#import "VideoDetailSectionTwoCell.h"
#import "VideoDetailSectionThreeCell.h"
#import "VideoDetailCommentCell.h"
#import <ZFPlayer/ZFAVPlayerManager.h>
#import <ZFPlayer/ZFPlayerControlView.h>
#import "AppDelegate.h"
#import <AVKit/AVKit.h>
#import "PopView.h"
#import <IQKeyboardManager.h>
#import "DVShareCustom.h"
@interface VideoDetailViewController ()<UITableViewDelegate,UITableViewDataSource,VideoDetailSectionThreeCellDelegate,VideoDetailSectionOneCellDelegate,PopViewDelegate, UITextFieldDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UITextField *contentTextF;
@property (nonatomic, assign) BOOL controlViewAppeared;
@property (nonatomic, strong) dispatch_block_t afterBlock;
@property (nonatomic, strong) NSDictionary *infoDic;  // 视频详情
@property (nonatomic, strong) NSDictionary *advInfoDic; // 广告详情
@property (nonatomic, strong) NSArray *recommendArray; // 可能喜欢
@property (nonatomic, strong) NSMutableArray *commentArray; // 评论

@property (nonatomic, strong) ZFPlayerController *player;
@property (nonatomic, strong) UIImageView *containerView;
@property (nonatomic, strong) ZFPlayerControlView *controlView;


@property (nonatomic, strong)AVPlayerViewController *playerVC;

@property (nonatomic, assign) NSInteger pageIndex;

@property (nonatomic, strong) HWDownloadModel *model;  // 数据模型

@property (nonatomic, strong) NSMutableDictionary *modelDic;  // 数据模型

@end

@implementation VideoDetailViewController

- (NSDictionary *)infoDic
{
    if (!_infoDic) {
        _infoDic = [NSDictionary dictionary];
    }
    return _infoDic;
}

- (NSDictionary *)advInfoDic
{
    if (!_advInfoDic) {
        _advInfoDic = [NSDictionary dictionary];
    }
    return _advInfoDic;
}

- (NSArray *)recommendArray
{
    if (!_recommendArray) {
        _recommendArray = [NSArray array];
    }
    return _recommendArray;
}

- (NSMutableArray *)commentArray
{
    if (!_commentArray) {
        _commentArray = [NSMutableArray array];
    }
    return _commentArray;
}

- (NSMutableDictionary *)modelDic
{
    if (!_modelDic) {
        _modelDic = [NSMutableDictionary dictionary];
    }
    return _modelDic;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.player.viewControllerDisappear = NO;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.player.viewControllerDisappear = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
//    [[IQKeyboardManager sharedManager] setEnable:NO];
    self.pageIndex = 1;
}

- (void)setupUI
{
    self.controlViewAppeared = NO;
//    self.commentNum = 12;
    UIView *headerView = [UIView new];
    headerView.backgroundColor = RGB_VALUE(0xDC0000);
    [self.view addSubview:headerView];
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.offset(0);
        make.height.mas_equalTo(Height_NavBar);
    }];
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setImage:[UIImage imageNamed:@"whiteBack"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [backBtn setHitEdgeInsets:UIEdgeInsetsMake(-15, -15, -15, -15)];
    [headerView addSubview:backBtn];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(-14);
        make.left.offset(18);
        make.width.height.mas_equalTo(16);
    }];
    
    UILabel *titleLabel = [UILabel new];
    titleLabel.text = @"详情";
    titleLabel.font = JSS_MEDIUM_FONT(17);
    titleLabel.textColor = RGB_VALUE(0xFFFFFF);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [headerView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(-9);
        make.centerX.offset(0);
        make.width.mas_equalTo(135);
        make.height.mas_equalTo(24);
    }];
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [loginBtn setImage:[UIImage imageNamed:@"MineCart"] forState:UIControlStateNormal];
    [loginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [headerView addSubview:loginBtn];
    [loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(titleLabel);
        make.width.mas_equalTo(72);
        make.right.offset(-2);
        make.height.mas_equalTo(22);
    }];
    
    self.containerView = [[UIImageView alloc] init];
    [self.view addSubview:self.containerView];
    [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_bottom).offset(0);
        make.left.right.offset(0);
        make.height.mas_equalTo(230);
    }];
    
    ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init];
    playerManager.shouldAutoPlay = YES;
    
    /// 播放器相关
    self.player = [ZFPlayerController playerWithPlayerManager:playerManager containerView:self.containerView];
    self.player.controlView = self.controlView;
//    self.player.shouldAutoPlay = NO;
    /// 设置退到后台继续播放
    self.player.pauseWhenAppResignActive = NO;
    
    @weakify(self)
    self.player.orientationWillChange = ^(ZFPlayerController * _Nonnull player, BOOL isFullScreen) {
        AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        delegate.allowOrentitaionRotation = isFullScreen;
    };
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) style:UITableViewStylePlain];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.backgroundColor = RGB_VALUE(0xF5F5F5);
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [_tableView registerClass:[VideoDetailSectionOneCell class] forCellReuseIdentifier:@"VideoDetailSectionOneCell"];
    [_tableView registerClass:[VideoDetailSectionTwoCell class] forCellReuseIdentifier:@"VideoDetailSectionTwoCell"];
    [_tableView registerClass:[VideoDetailSectionThreeCell class] forCellReuseIdentifier:@"VideoDetailSectionThreeCell"];
    [_tableView registerClass:[VideoDetailCommentCell class] forCellReuseIdentifier:@"VideoDetailCommentCell"];
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    [self.view addSubview:_tableView];
    CGFloat bottomOffset = TabbarSafeBottomMargin + 70;
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.equalTo(self.containerView.mas_bottom).offset(0);
        make.bottom.offset(-bottomOffset);
    }];
    
    self.contentTextF = [InsetsTextField new];
    self.contentTextF.placeholder = @"我想说点什么";
    self.contentTextF.font = JSS_MEDIUM_FONT_5;
    self.contentTextF.textColor = RGB_VALUE(0xA5A5A5);
    self.contentTextF.layer.masksToBounds = YES;
    self.contentTextF.layer.cornerRadius = 15;
    self.contentTextF.delegate = self;
    self.contentTextF.returnKeyType = UIReturnKeySend;
    self.contentTextF.backgroundColor = RGB_VALUE(0xE3E3E6);
    CGFloat bottomOffset1 = IS_IPHONE_X_TOP ? (5+TabbarSafeBottomMargin) : 5;
    [self.view addSubview:self.contentTextF];
    [self.contentTextF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.bottom.offset(-bottomOffset1);
        make.right.offset(-16);
        make.height.mas_equalTo(56);
    }];
    
    self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
        @strongify(self)
        self.pageIndex ++;
        [self requestCommentList];
    }];
    
//    self.detailID = @"6";
    NSString *urlstring = [NSString stringWithFormat:@"material/%@",self.detailID];
    // 评论列表
    [self requestCommentList];
    // 其他数据
    [[APIManager sharedNetManager] requestWithMethod:HttpRequestTypeGet URLString:urlstring parameters:@{} done:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
        self.infoDic = responseObject[@"data"][@"info"];
        
//        NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];//WithDictionary:responseObject[@"data"][@"info"]];
        [self.modelDic setValue:self.detailID forKey:@"vid"];
        [self.modelDic setValue:self.infoDic[@"title"] forKey:@"fileName"];
        [self.modelDic setValue:self.infoDic[@"uuid"] forKey:@"uuid"];
        [self.modelDic setValue:self.infoDic[@"copyright"] forKey:@"copyright"];
        [self.modelDic setValue:self.infoDic[@"suffix"] forKey:@"suffix"];
        [self.modelDic setValue:self.infoDic[@"sort_name"] forKey:@"sortName"];
        [self.modelDic setValue:self.infoDic[@"size"] forKey:@"size"];
        [self.modelDic setValue:self.infoDic[@"create_day"] forKey:@"createDay"];
        [self.modelDic setValue:self.infoDic[@"intro"] forKey:@"intro"];
        [self.modelDic setValue:self.infoDic[@"type"] forKey:@"type"];
        [self.modelDic setValue:self.infoDic[@"thumb"] forKey:@"thumb"];
        [self.modelDic setValue:self.infoDic[@"compress_url"] forKey:@"url"];
        
        self.advInfoDic = responseObject[@"data"][@"adv"];
        self.recommendArray = responseObject[@"data"][@"commend_list"];
//        self.commentArray = responseObject[@"data"][@"comment_list"];
                
        if ([self.infoDic[@"type"] integerValue] == 3) { // 图片
            [self.containerView m_setImageWithUrlString:self.infoDic[@"thumb"] placeholder:@"placeholderImg"];
        } else {
            self.player.assetURL = [NSURL URLWithString:self.infoDic[@"compress_url"]];
            [self.containerView m_setImageWithUrlString:self.infoDic[@"thumb"] placeholder:@"placeholderImg"];
            [self.controlView showTitle:@"" coverURLString:self.infoDic[@"thumb"] fullScreenMode:ZFFullScreenModeAutomatic];
        }
        // 如果是语音的话，就加上子视图
        if ([self.infoDic[@"type"] integerValue] == 2) {
            UIImageView *temp = [[UIImageView alloc] init];
            temp.backgroundColor = UIColor.whiteColor;
            temp.frame = CGRectMake(0, 0, kDeviceWidth, 230);
            [temp m_setImageWithUrlString:self.infoDic[@"thumb"] placeholder:@"videoDetailBG"];
//            temp.image = [UIImage imageNamed:@"videoDetailBG"];
//            temp.contentMode = UIViewContentModeScaleAspectFit;
            [self.controlView insertSubview:temp belowSubview:self.controlView.portraitControlView];
        }
        
        // 这是播放本地缓存视频的代码
//        NSURL *videoURL = [NSURL fileURLWithPath:self.downLoadmodel.localPath];
//        self.player.assetURL = videoURL;//[NSURL URLWithString:@"https://www.apple.com/105/media/cn/mac/family/2018/46c4b917_abfd_45a3_9b51_4e3054191797/films/bruce/mac-bruce-tpl-cn-2018_1280x720h.mp4"];
//        NSString *tempCover = @"https://upload-images.jianshu.io/upload_images/635942-14593722fe3f0695.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
//        [self.containerView m_setImageWithUrlString:tempCover placeholder:@"placeholderImg"];
//        [self.controlView showTitle:@"" coverURLString:tempCover fullScreenMode:ZFFullScreenModeAutomatic];
        
        [self.tableView reloadData];
    } fail:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        
//        self.player.assetURL = [NSURL URLWithString:@"http://39.105.153.211/uploads/file_material/20200807/159680640205a72a8f074c2907.mp3"];
        NSString *documentsDirecroty = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject;
        NSString *fullPath = [NSString stringWithFormat:@"%@/%@/%@", documentsDirecroty,kDVDownLoadFileName, @"50a93e8ec43ba98091d7fa5bf5f71769_compress.mp4"];
        NSURL *videoURL = [NSURL fileURLWithPath:fullPath];
        self.player.assetURL = videoURL;
        NSString *tempCover = @"https://upload-images.jianshu.io/upload_images/635942-14593722fe3f0695.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
        [self.containerView m_setImageWithUrlString:tempCover placeholder:@"placeholderImg"];
        [self.controlView showTitle:@"" coverURLString:tempCover fullScreenMode:ZFFullScreenModeAutomatic];
        
        
//        NSString *documentsDirecroty = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject;
////        NSString *fullPath = [NSString stringWithFormat:@"%@/%@", documentsDirecroty, @"mac-bruce-tpl-cn-2018_1280x720h.mp4"];
//        NSString *fullPath = [NSString stringWithFormat:@"%@/quehua_movie_file/%@", documentsDirecroty, @"mac-bruce-tpl-cn-2018_1280x720h.mp4"];
//        NSURL *videoURL = [NSURL fileURLWithPath:fullPath];
//        self.playerVC = [[AVPlayerViewController alloc] init];
//        self.playerVC.player = [AVPlayer playerWithURL:videoURL];
//        [self.view addSubview:self.playerVC.view];
//        [self.playerVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(Height_NavBar);
//            make.left.right.offset(0);
//            make.height.mas_equalTo(230);
//        }];
//
//        [self.playerVC.player play];
        
        // 如果是语音的话，就加上子视图
//        if () {
//           UIView *temp = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, 230)];
//           temp.backgroundColor = UIColor.redColor;
//           [self.controlView insertSubview:temp belowSubview:self.controlView.portraitControlView];
//        }
    }];
    
    /// 播放完成
    self.player.playerDidToEnd = ^(id  _Nonnull asset) {
        @strongify(self)
        
    };
    
    self.player.playerPlayStateChanged = ^(id<ZFPlayerMediaPlayback>  _Nonnull asset, ZFPlayerPlaybackState playState) {
        @strongify(self)
        if (playState == ZFPlayerPlayStatePlaying) {

        } else if (playState == ZFPlayerPlayStatePaused) {

        } else if (playState == ZFPlayerPlayStatePlayStopped) {
            NSTimeInterval timeinter = 0;
            [self.player.currentPlayerManager seekToTime:timeinter completionHandler:^(BOOL finished) {
                [self.player.currentPlayerManager pause];
                [self.controlView.portraitControlView showControlView];
            }];
        }
    };
}

- (void)requestCommentList
{
    NSDictionary *paramDic = @{
        @"id":self.detailID,
        @"page":@(self.pageIndex),
        @"limit":@(10)
    };
    [[APIManager sharedNetManager] requestWithMethod:HttpRequestTypePost URLString:@"commentlist" parameters:paramDic done:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
        if (self.pageIndex == [responseObject[@"data"][@"comment_list"][@"page_sum"] integerValue]) {
            [self.tableView.mj_footer endRefreshingWithNoMoreData];
        } else {
            [self.tableView.mj_footer endRefreshing];
        }
        [self.commentArray addObjectsFromArray:responseObject[@"data"][@"comment_list"][@"list"]];
        [self.tableView reloadSection:3 withRowAnimation:UITableViewRowAnimationNone];
    } fail:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        
    }];
}

- (void)backBtnClick
{
    [self pop];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    NSDictionary *paramDic = @{
        @"id":self.detailID,
        @"content":textField.text
    };
    [[APIManager sharedNetManager] requestWithMethod:HttpRequestTypePost URLString:@"comment" parameters:paramDic done:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
        self.pageIndex = 1;
        [self requestCommentList];
    } fail:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        
    }];
    return YES;
}

// 跳转到购物车
- (void)loginBtnClick
{
    MineCartViewController *vc = [[MineCartViewController alloc] init];
    [self pushVc:vc];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    } else if (section == 1) {
        return 1;
    } else if (section == 2) {
        return 1;
    } else if (section == 3) {
        return self.commentArray.count;
    }
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        VideoDetailSectionOneCell *cell = [VideoDetailSectionOneCell cellWithTableView:tableView];
        cell.dataDic = self.infoDic;
        cell.delegate = self;
        return cell;
    } else if (indexPath.section == 1) {
        VideoDetailSectionTwoCell *cell = [VideoDetailSectionTwoCell cellWithTableView:tableView];
        cell.dataDic = self.advInfoDic;
        return cell;
    } else if (indexPath.section == 2) {
        VideoDetailSectionThreeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VideoDetailSectionThreeCell"];
        cell.delegate = self;
        cell.dataArray = self.recommendArray;
        return cell;
    } else if (indexPath.section == 3) {
        VideoDetailCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VideoDetailCommentCell"];
        cell.dataDic = self.commentArray[indexPath.row];
        return cell;
    }
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        CGSize sizes = [self.infoDic[@"intro"] boundingRectWithSize:CGSizeMake(kDeviceWidth - 50, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:JSS_MEDIUM_FONT_3} context:nil].size;
        return 295 + sizes.height;
    } else if (indexPath.section == 1) {
        return 130;
    } else if (indexPath.section == 2) {
        return 160;
    } else if (indexPath.section == 3) {
        NSString *dd = self.commentArray[indexPath.row][@"content"];
        CGSize sizes = [dd boundingRectWithSize:CGSizeMake(kDeviceWidth - 100, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:JSS_MEDIUM_FONT_3} context:nil].size;
        return 70 + sizes.height;
    }
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 3) {
        UIView *view = [UIView new];
        view.backgroundColor = RGB_VALUE(0xF5F5F5);
        UILabel *titleLabel = [UILabel new];
        titleLabel.text = [NSString stringWithFormat:@"全部评论%ld",(long)self.commentArray.count];
        titleLabel.font = JSS_MEDIUM_FONT(15);
        [view addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(0);
            make.left.offset(20);
            make.right.offset(-21);
            make.height.mas_equalTo(20);
        }];
        return view;
    }
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section
{
    if (section == 3) {
        return 30;
    }
    return 0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

- (void)tapVideoDetailSectionThreeCellWithData:(NSDictionary *)data
{
    [self pushVideoDetailVCWithID:data[@"id"]];
}

- (void)VideoDetailSectionOneCellClickBtn:(NSInteger)btnTag
{
    if (btnTag == 666) { // 购买
        NSDictionary *paramDic = @{
            @"order_type":@"1",
            @"id":self.detailID,
            @"price":@"2", // 这里要decimal类型的参数
            @"pay_type":@"2" // 支付方式 1微信 2支付宝 3银联
        };
        [[APIManager sharedNetManager] requestWithMethod:HttpRequestTypePost URLString:@"buyorder" parameters:paramDic done:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
            
        } fail:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
            
        }];
    } else if (btnTag == 667) { // 举报
        PopView *popView = [[PopView alloc] initWithStyle:KComplainType];
        popView.delegate = self;
    } else if (btnTag == 668) { // 下载
        
        NSString *urlstring = [NSString stringWithFormat:@"download/%@",self.detailID];
        [[APIManager sharedNetManager] requestWithMethod:HttpRequestTypeGet URLString:urlstring parameters:@{} done:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
            
        } fail:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
            NSLog(@"失败");
        }];
        
        [self.modelDic setValue:[NSDate yearMDForDate:[NSDate date]] forKey:@"dowmLoadDate"];
        self.model = [HWDownloadModel mj_objectWithKeyValues:self.modelDic];
        
        HWDownloadModel *tempModel = [[HWDataBaseManager shareManager] getModelWithUrl:self.model.url];
        if (tempModel.state == HWDownloadStateFinish) {
            [TipView showMessage:@"已经缓存过了"];
            return;
        }
        if (tempModel.state == HWDownloadStateDownloading) {
            [TipView showMessage:@"下载中,请稍等"];
            return;
        }
        
        if (self.model.state == HWDownloadStateDefault || self.model.state == HWDownloadStatePaused || self.model.state == HWDownloadStateError) {
            // 点击默认、暂停、失败状态，调用开始下载
            [[HWDownloadManager shareManager] startDownloadTask:_model];
            [TipView showMessage:@"开始下载"];
        }
//        else if (self.model.state == HWDownloadStateDownloading || self.model.state == HWDownloadStateWaiting) {
            // 点击正在下载、等待状态，调用暂停下载
//            [[HWDownloadManager shareManager] pauseDownloadTask:_model];
//            [TipView showMessage:@"下载中,请稍等"];
//        }
        
    } else if (btnTag == 669) { // 加购物车
        
        [[APIManager sharedNetManager] requestWithMethod:HttpRequestTypePost URLString:@"cart" parameters:@{@"id":self.detailID} done:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
            
        } fail:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
            
        }];
        
    } else if (btnTag == 670) { // 版权购买
        
    } else if (btnTag == 671) { // 分享
        NSMutableDictionary * params = [NSMutableDictionary dictionary];
//        [params SSDKSetupShareParamsByText:model.content
//                                    images:model.coverImage
//                                       url:[NSURL URLWithString:model.linkUrl]
//                                     title:model.title
//                                      type:SSDKContentTypeAuto];
        [DVShareCustom shareWithContent:params];
    }
}

- (void)PopViewEnsureClickWithType:(PopViewType)type content:(nonnull NSString *)content
{
    NSLog(@"%ld",(long)type);
    NSDictionary *paramDic = @{
        @"id":self.detailID,
        @"content":content
    };
    [[APIManager sharedNetManager] requestWithMethod:HttpRequestTypePost URLString:@"report" parameters:paramDic done:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
        
    } fail:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        
    }];
}

- (ZFPlayerControlView *)controlView {
    if (!_controlView) {
        _controlView = [ZFPlayerControlView new];
        _controlView.fastViewAnimated = YES;
        _controlView.autoHiddenTimeInterval = 5;
        _controlView.autoFadeTimeInterval = 0.5;
        _controlView.prepareShowLoading = YES;
        _controlView.prepareShowControlView = NO;
    }
    return _controlView;
}
@end
